<?php
/**
 * 品牌产品列表文件
 *
 * @author		Arthur(ArthurXF@gmail.com)
 * @copyright	(c) 2006 by bizeway.com
 * @version		$Id$
 * @package		ArthurXF
 * @subpackage	product
 */
require_once('../product/config/config.inc.php');
require_once("../product/class/product.class.php");

$objWebInit = new product();
//数据库连接参数
$objWebInit->setDBG($arrGPdoDB);
//smarty参数
$objWebInit->arrGSmarty = $arrGSmarty;
//图像参数
$objWebInit->arrGPic = $arrGPic;
//翻页参数
$objWebInit->arrGPage = $arrGPage;
$objWebInit->db();

//产品分类
include '../product/block/_menu.php';
include '../product/block/child_type.php';
$arrMOutput["smarty_assign"]['strBlock1'] = "brand/block/getprotype.html";
$arrMOutput["smarty_assign"]['strBlock2'] = "product/block/_menu.html";

//类别ID
$arrWhere = array();
$arrLink = array();
$arrWhere[] = "pass='1'";

if(!empty($_GET['type_id'])){
	$intTypeID = intval($_GET['type_id']);
	$arrWhere[] = "type_id='".$intTypeID."'";
	$arrLink[] = 'type_id=' . $intTypeID;
}
if(!empty($_GET['brand_id'])){
	$intBrandID = intval($_GET['brand_id']);
	$arrWhere[] = "brand_id='".$intBrandID."'";
	$arrLink[] = 'brand_id=' . $intBrandID;
}
if(empty($_GET['page'])) {
	$intPage = 1 ;
} else {
	$intPage = intval($_GET['page']);
}
$strWhere = implode(' AND ',$arrWhere);
$strWhere = 'where '.$strWhere;

$strOrder = ' ORDER BY topflag DESC';

//关注度
if (isset($_GET['click'])){
	$intTemp = intval($_GET['click']);
	if($intTemp == 2) $strOrder .= ',clicktimes desc';
	else  $strOrder .= ',clicktimes asc';
}
//价格
if (isset($_GET['price'])){
	$intTemp = intval($_GET['price']);
	if($intTemp == 2) $strOrder .= ',my_price desc';
	else  $strOrder .= ',my_price asc';
}
//上架时间
if (isset($_GET['date'])){
	$intTemp = intval($_GET['date']);
	if($intTemp == 2) $strOrder .= ',submit_date desc';
	else  $strOrder .= ',submit_date asc';
}else $strOrder .= ',submit_date desc';

$arrInfoList = $objWebInit->getInfoList($strWhere,$strOrder,($intPage-1)*$arrGPage['page_size'],$arrGPage['page_size']);
$intRows = $arrInfoList['COUNT_ROWS'];
unset($arrInfoList['COUNT_ROWS']);

if(!empty($_GET['type_id'])){
	$arrTypeInfo = $objWebInit->getTypeInfo($intTypeID);

	$arrMOutput["smarty_assign"]['arrType'] = $arrTypeInfo;
	$arrMOutput['smarty_assign']['Title'] = $arrTypeInfo['type_title'].' - '.$arrGWeb['name'];
	$arrMOutput['smarty_assign']['Description'] = $arrTypeInfo['type_title'].' - '.$arrGWeb['name'];
	$arrMOutput['smarty_assign']['Keywords'] = $arrTypeInfo['type_title'].' - '.$arrGWeb['name'];
}
if(!empty($_GET['brand_id'])){
	//品牌数组
	include_once(__WEB_ROOT.'/brand/class/brand.class.php');
	include_once(__WEB_ROOT.'/brand/config/var.inc.php');
	$objBrand = new brand();
	$objBrand->setDBG($arrGPdoDB);
	$objBrand->arrGPic=$arrGPic;
	$objBrand->db();
	$arrBrandInfo = $objBrand->getInfo($intBrandID);

	$arrMOutput["smarty_assign"]['brandImg'] = $objBrand->arrGPic['FileCallPath'];
	$arrMOutput["smarty_assign"]['arrBrandInfo'] = $arrBrandInfo;
	$arrMOutput['smarty_assign']['Title'] = $arrTypeInfo['type_title'].$arrBrandInfo['title'].' - '.$arrGWeb['name'];
	$arrMOutput['smarty_assign']['Description'] = $arrTypeInfo['type_title'].$arrBrandInfo['title'].' - '.$arrGWeb['name'];
	$arrMOutput['smarty_assign']['Keywords'] = $arrTypeInfo['type_title'].$arrBrandInfo['title'].' - '.$arrGWeb['name'];
}

//静态url处理
if($arrGWeb['URL_static']){
	if (!empty($arrLink)) $strLink = str_replace('=','-',implode('-',$arrLink));
}else{
	if (!empty($arrLink)) $strLink = implode('&',$arrLink);
}
//翻页跳转link
$strPage= $objWebInit->makeInfoListPage($intRows,$strLink,$link_type=$arrGWeb['URL_static']);

//全站公用block
@include '../_block.php';

//输出到模板
$arrMOutput["smarty_assign"]['arrInfoList'] = $arrInfoList;
$arrMOutput["smarty_assign"]['FileCallPath'] = $objWebInit->arrGPic['FileCallPath'];
$arrMOutput["smarty_assign"]['strPage'] = $strPage;
$arrMOutput["smarty_assign"]['MAIN'] = $arrGSmarty['main_dir'].'list.html';
$objWebInit->output($arrMOutput);
?>